package com.llamarun;

import android.media.MediaPlayer;

public class Music {
	private MediaPlayer mMediaPlayer;

	// ===========================================================
	// Constructors
	// ===========================================================

	Music(final MediaPlayer pMediaPlayer) {
		

		this.mMediaPlayer = pMediaPlayer;
	}

	// ===========================================================
	// Getter & Setter
	// ===========================================================

	public boolean isPlaying() {
		return this.mMediaPlayer.isPlaying();
	}

	public MediaPlayer getMediaPlayer() {

		return this.mMediaPlayer;
	}

	// ===========================================================
	// Methods for/from SuperClass/Interfaces
	// ===========================================================

	
	public void play() {
		this.mMediaPlayer.start();
	}


	public void stop() {

		this.mMediaPlayer.stop();
	}

	
	public void resume() {

		this.mMediaPlayer.start();
	}


	public void pause() {

		this.mMediaPlayer.pause();
	}


	public void setLooping(final boolean pLooping) {

		this.mMediaPlayer.setLooping(pLooping);
	}

//	@Override
//	public void setVolume(final float pLeftVolume, final float pRightVolume) throws MusicReleasedException {
//		super.setVolume(pLeftVolume, pRightVolume);
//
//		final float masterVolume = this.getAudioManager().getMasterVolume();
//		final float actualLeftVolume = pLeftVolume * masterVolume;
//		final float actualRightVolume = pRightVolume * masterVolume;
//
//		this.mMediaPlayer.setVolume(actualLeftVolume, actualRightVolume);
//	}

//	@Override
//	public void onMasterVolumeChanged(final float pMasterVolume) throws MusicReleasedException {
//		this.setVolume(this.mLeftVolume, this.mRightVolume);
//	}


	public void release() {

		this.mMediaPlayer.release();
		this.mMediaPlayer = null;

		
	}

	// ===========================================================
	// Methods
	// ===========================================================

	public void seekTo(final int pMilliseconds) {
		this.mMediaPlayer.seekTo(pMilliseconds);
	}

//	public void setOnCompletionListener(final OnCompletionListener pOnCompletionListener) throws MusicReleasedException {
//		this.assertNotReleased();
//
//		this.mMediaPlayer.setOnCompletionListener(pOnCompletionListener);
//	}

}
